/**
 * 商品管理-属性管理
 */
import request from "@/utils/request";
import {Attr} from './type.ts'

enum API {
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTRINFOLIST_URL = '/admin/product/attrInfoList/',
  DELATTR_URL = '/admin/product/deleteAttr/',
  SAVEATTRINFO_URL = '/admin/product/saveAttrInfo',
  ATTRVALUELIST_URL = '/admin/product/getAttrValueList/'
}

// 获取属性管理一级下拉菜单数据
export const getC1 = () => request.get<any, any>(API.C1_URL)
// 获取属性管理二级下拉菜单数据
export const getC2 = (category1Id: number) => request.get<any, any>(API.C2_URL + `${category1Id}`)
// 获取属性管理三级下拉菜单数据
export const getC3 = (category2Id: number) => request.get<any, any>(API.C3_URL + `${category2Id}`)
// 根据一级二级三级菜单的id获取属性列表
export const getAttrInfoList = (category1Id: number, category2Id: number, category3Id: number) => request.get<any, any>(API.ATTRINFOLIST_URL + `${category1Id}/${category2Id}/${category3Id}`)
// 删除某属性树数据
export const delAttrItem = (attrId: number) => request.delete<any, any>(API.DELATTR_URL + attrId)
// 添加或修改已有属性值属性信息数据
export const saveAttrInfoAPI = (data:Attr) => request.post<any, any>(API.SAVEATTRINFO_URL, data)
// 获取属性值列表
export const getAttrValueList = (attrId) => request.get<any,any>(API.ATTRVALUELIST_URL + attrId)
